package com.kermel.andromeda.activities.triggered;

import android.app.Activity;
import android.content.Context;
import android.view.View;

import com.kermel.andromeda.data.Alarm;
import com.kermel.andromeda.data.AlarmManager;

public class SnoozeTriggeredAlarmAction extends AbstractTriggeredAlarmActivityAction {
    public SnoozeTriggeredAlarmAction(Activity activity, Alarm alarm) {
        super(activity, alarm);
    }
    
    public void onClick(View v) {
        if (isAlarmNull()) {
            // TODO: Display error to user via Toast
            System.err.println("Unable to retrigger alarm because SnoozeTriggerAlarm.alarm is null");
            return;
        }
        
        adjustAlarmToRetrigger();
        causeActivityToFinish();
    }
    
    private void adjustAlarmToRetrigger() {
        Alarm alarm = getAlarm();
        Context context = getContext();
        AlarmManager.instance.adjustAlarmToRetriggerAtEndOfSnoozePeriod(alarm, context);
    }

}
